﻿using System;
using System.Text;
using System.Collections.Generic;
using System.Linq;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using DeepZoomPivotConstructor;
using System.IO;
using DeepZoomPivotConstructor.VisualLib;

namespace t_VisualLib
{
    /// <summary>
    /// Summary description for t_VisualItemPlaceHolder
    /// </summary>
    [TestClass]
    public class t_VisualItemPlaceHolder
    {
        public t_VisualItemPlaceHolder()
        {
        }

        private TestContext testContextInstance;

        /// <summary>
        ///Gets or sets the test context which provides
        ///information about and functionality for the current test run.
        ///</summary>
        public TestContext TestContext
        {
            get
            {
                return testContextInstance;
            }
            set
            {
                testContextInstance = value;
            }
        }

        #region Additional test attributes
        //
        // You can use the following additional attributes as you write your tests:
        //
        // Use ClassInitialize to run code before running the first test in the class
        // [ClassInitialize()]
        // public static void MyClassInitialize(TestContext testContext) { }
        //
        // Use ClassCleanup to run code after all tests in a class have run
        // [ClassCleanup()]
        // public static void MyClassCleanup() { }
        //
        // Use TestInitialize to run code before running each test 
        // [TestInitialize()]
        // public void MyTestInitialize() { }
        //
        // Use TestCleanup to run code after each test has run
        // [TestCleanup()]
        // public void MyTestCleanup() { }
        //
        #endregion

        [TestMethod]
        public void TestBasicCreation()
        {
            VisualItemPlaceHolder vh = new VisualItemPlaceHolder(5.0, 3.0, new FileInfo("junk.jpg"), new Visual.VisualInfo());
            Assert.AreEqual(5.0, vh.Width, "Width");
            Assert.AreEqual(3.0, vh.Height, "Height");
            Assert.AreEqual(1, vh.ZIndex, "ZIndex");
            Assert.AreEqual(0.0, vh.XPosition, "XPosition");
            Assert.AreEqual(0.0, vh.YPosition, "YPosition");
            Assert.AreEqual(0, vh.SGNodeList.Count(), "SGNodeList");
            Assert.AreEqual("junk.jpg", vh.XMLFile.Name, "XMLFile");
            Assert.IsTrue(vh.IsCompositionUnit, "Should be compositional unit!");
            Assert.AreEqual("junk", vh.ComposableUnitName, "The composable unit name wasn't set right!");
        }

        [TestMethod]
        public void TestScaleing()
        {
            VisualItemPlaceHolder vh = new VisualItemPlaceHolder(5.0, 3.0, new FileInfo("junk.jpg"), new Visual.VisualInfo());
            vh.Scale(0.5);
            Assert.AreEqual(2.5, vh.Width, "Width didn't scale right");
            Assert.AreEqual(1.5, vh.Height, "Height is quite tiny");
        }

        [TestMethod]
        public void TestPositions()
        {
            VisualItemPlaceHolder vh = new VisualItemPlaceHolder(5.0, 3.0, new FileInfo("junk.jpg"), new Visual.VisualInfo());
            vh.XPosition = 1.0;
            vh.YPosition = 2.0;
            Assert.AreEqual(1.0, vh.XPosition, "XPosition");
            Assert.AreEqual(2.0, vh.YPosition, "YPosition");
        }

        [TestMethod]
        public void TestInfo()
        {
            Visual.VisualInfo info = new Visual.VisualInfo();
            info.Title = "hi";
            VisualItemPlaceHolder vh = new VisualItemPlaceHolder(5.0, 3.0, new FileInfo("junk.jpg"), info);
            Assert.AreEqual("hi", vh.Info.Title);
        }

        [TestMethod]
        public void TestZIndex()
        {
            VisualItemPlaceHolder vh = new VisualItemPlaceHolder(5.0, 3.0, new FileInfo("junk.pjg"), new Visual.VisualInfo());
            Assert.AreEqual(vh.ZIndex, 1, "ZIndex not initalized correctly");
            vh.IncZIndex();
            Assert.AreEqual(vh.ZIndex, 2, "ZIndex not incremented correctly");
        }
    }
}
